from django.utils import simplejson
from poi import POI
from google.appengine.ext import webapp
import models, settings

class POIHandler(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-type'] = 'text/javascript; charset=utf-8'
        template_values = settings.base_template_data(self.request)
        user_pois = [poi for poi in models.POI.gql('where user = :1 AND private = True', template_values['local_user'])]
        public_pois = [poi for poi in models.POI.gql('where private = False')]
        if not(user_pois): user_pois=[]
        if not(public_pois): public_pois=[]
        pois = [POI(poi).get_dict() for poi in (user_pois + public_pois)]
        d = {'layer':'layarauthorer', 'hotspots':pois, 'errorCode':0, 'errorString':'ok'}
        d['action'] = {'uri':'http://google.com','label':'add current location'}
        self.response.out.write(simplejson.dumps(d))

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
